package com.example.demo.generator.service.impl;

import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.generator.entiy.Test;
import com.example.demo.generator.mapper.TestMapper;
import com.example.demo.generator.service.TestService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestServiceImpl extends ServiceImpl<TestMapper, Test>
    implements TestService {

    @Override
    public R test(Integer pageNum, Integer pageSize) {
        PageInfo<Test> pageInfo = new PageInfo<>();
        if(pageNum!=null){
            if(pageSize!=null) {
                PageHelper.startPage(pageNum, pageSize);
                List<Test> testList = this.list(null);
                pageInfo = new PageInfo<>(testList);
            }
        }else {
            List<Test>testList = this.list(null);
            return R.ok(testList);
        }
        return R.ok(pageInfo);
    }
}
